var jsonwebtoken = require('jsonwebtoken')
var mqtt = require('mqtt')
require("dotenv").config() //配置文件插件
var username = "yxqz"
var password = jsonwebtoken.sign(
    {
    username: username,
    exp: Math.floor(Date.now() / 1000) + 10
}, process.env.JWT_SECRET)

console.log('用户名：',username)
console.log('密码:',password)

setTimeout(function () {
    console.log("延迟了3秒钟")
},3000);

var client = mqtt.connect(process.env.MQTT_URL, {
    username: username,
    password: password
})

client.on('connect', function (connack) {
    console.log(`return code: ${connack.returnCode}`)
    client.end()
})

client.on("error", function (err) {
})